package com.wch.search.service;

import com.wch.search.dao.ArticleSearchDao;
import com.wch.search.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Service;

@Service
public class ArticleSearchService {

    @Autowired
    private ArticleSearchDao articleSearchDao;



    /**
     * 增加文章
     * @param article
     */
    public void add(Article article){
        articleSearchDao.save(article);
    }

    public Page<Article> findByTitleLike(String keyword,int page,int size){
        PageRequest pageRequest = PageRequest.of(page-1,size);
        return articleSearchDao.findByTitleOrContentLike(keyword,keyword,pageRequest);
    }
}
